#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "ui_mainwindow.h"

class QAction;
class QLabel;
class Spreadsheet;
class FindDialog;
class GoToCellDialog;
class QMessageBox;
class ExtDlg;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow, public Ui::MainWindow {
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;

protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void newFile();
    void open();
    bool save();
    bool saveAs();
    void close();
    void find();
    void goToCell();
    void sort();
    void about();
    void openRecentFile();
    void updateStatusBar();
    void spreadsheetModified();
private:
    void createActions();
    void createMenus();
    void createContextMenu();
    void createToolBars();
    void createStatusBars();
    void readSettings();
    void writeSettings();
    bool okToContinue();
    bool loadFile(const QString &fileName);
    bool saveFile(const QString &fileName);
    void setCurrentFile(const QString &fileName);
    void updateRecentFileActions();
    QString strippedName(const QString &fullFileName);

    Spreadsheet *spreadsheet;
    FindDialog *findDialog;
    QLabel *locationLabel;
    QLabel *formulaLabel;
    QStringList recentFiles;
    QString curFile;

    enum {MaxRecentFiles = 5};

    QAction *recentFileActions[MaxRecentFiles];
    QAction *separatorAction;

    QMenu *fileMenu;
    QMenu *editMenu;
    QMenu *selectSubMenu;
    QMenu *toolsMenu;
    QMenu *optionsMenu;
    QMenu *helpMenu;

    QToolBar *fileToolBar;
    QToolBar *editToolBar;

    QAction *newAction;//
    QAction *openAction;//
    QAction *saveAction;//
    QAction *saveAsAction;//
    QAction *exitAction;//
    QAction *closeAction;//
    QAction *cutAction;//
    QAction *copyAction;//
    QAction *pasteAction;//
    QAction *deleteAction;//

    QAction *selectRowAction;//
    QAction *selectColumnAction;
    QAction *selectAllAction;//

    QAction *recalculateAction;
    QAction *sortAction;

    QAction *showGridAction;//
    QAction *autoRecalcAction;

    QAction *findAction;
    QAction *goToCellAction;

    QAction *aboutAction;
    QAction *aboutQtAction;//
};

#endif